<?php


namespace App\Http\Controllers\Api\v1;


use App\common;

use App\Logic\LabeLLogic;
use App\Logic\SecondaryLogic;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

/**
 * @name wjy
 * Class LabelController
 * @package App\Http\Controllers\Api\v1
 * 房源标签管理
 */
class LabelController extends Controller
{
    /**
     * 房源标签展示列表
     */
    public function LabelList(){
        try {
            $Secondary=LabeLLogic::Secondary();
            return common::success(20000,$Secondary,'房源标签展示成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 数据库信息同步存入redis
     * @return array|false|string
     */
    public function redisLabelList(){
        try {
            $Secondary = LabeLLogic::redisLabelList();
            return common::success(20000, $Secondary, '房源标签展示成功存入redis');
        } catch (\Exception $exception) {
            return common::fail('', "", $exception->getMessage());
        }
    }
    /**
     * 房源标签添加
     */
    public function LabelAdd(Request $request){
        try {
            $SecondaryAdd=LabeLLogic::SecondaryAdd($request);
            return common::success(20000,$SecondaryAdd,'房源标签添加成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }

    /**
     * 房源标签删除
     */
    public function LabelDel(Request $request){
        try {
            $fangId=$request->get('id');
            $secondaryMessage=LabeLLogic::SecondaryDel($fangId);
            return common::success(20000,$secondaryMessage,'房源标签删除成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 房源标签查找
     */
    public function LabelSeek(Request $request){
        try {
            $keyword=$request->get('keyword');
            $SecondaryMessage=LabeLLogic::SecondarySeek($keyword);
            return common::success(20000,$SecondaryMessage,'房源标签搜索成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 房源标签详情
     */
    public function LabelDetails(Request $request){
        try {
            $fangId=$request->get('id');
            $SecondaryMessage=LabeLLogic::SecondaryDetails($fangId);
            return common::success(20000,$SecondaryMessage,'房源标签详情展示成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 房源标签修改
     */
    public function LabelUpdated(Request $request){
        try {
            $SecondaryMessageUpdated = $request->post();
            $SecondaryAdd=LabeLLogic::SecondaryUpdated($SecondaryMessageUpdated);
            return common::success(20000,$SecondaryAdd,'房源标签修改成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 房源标签es搜索
     */
    public function LabelSearch(Request $request){
        try {
            $keyword=$request->get('keyword');
            $SecondaryMessage=LabeLLogic::SecondarySearch($keyword);
            return common::success(20000,$SecondaryMessage,'房源标签es搜索成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
}
